cmake_minimum_required( VERSION 2.8 )
project(px4_control)

set( CMAKE_CXX_FLAGS "-std=c++14" )

set(CMAKE_C_FLAGS "-pthread -std=gnu99")
set(CMAKE_EXE_LINKER_FLAGS "-pthread")
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")

execute_process(COMMAND uname -m
        OUTPUT_VARIABLE DEVICE_SYSTEM_ID)
message(WARNING " device system id: ${DEVICE_SYSTEM_ID}")

if (DEVICE_SYSTEM_ID MATCHES x86_64)
    add_definitions(-DPLATFORM_ARCH_x86_64=1)
elseif (DEVICE_SYSTEM_ID MATCHES aarch64)
    add_definitions(-DPLATFORM_ARCH_aarch64=1)
else ()
    message(FATAL_ERROR "FATAL: Please confirm your platform.")
endif ()


set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty)

find_package( OpenCV 4 REQUIRED)
add_definitions(-DOPENCV4)


find_package(FFMPEG REQUIRED)


# for ekf type , here use Pdot = F * P * F' + Q
add_definitions(-DEKF_UPDATE_DISCRETE)

include_directories(
	/usr/local/include/mavsdk
	/usr/local/include/mavsdk/plugins
	src
  	${OpenCV_INCLUDE_DIRS}
  	${FFMPEG_INCLUDE_DIR}
  )


add_executable(px4_control  	src/main.cpp
								src/px4_flight_handler.cpp)


target_link_libraries( px4_control  	${OpenCV_LIBS}
										${FFMPEG_LIBRARIES}
										/usr/local/lib/libmavsdk.so
										/usr/local/lib/libmavsdk_telemetry.so
										/usr/local/lib/libmavsdk_action.so
										/usr/local/lib/libmavsdk_offboard.so
										/usr/local/lib/libmavsdk_mission.so)
